package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.MeterKind;
import com.lrkj.payfee.service.IMeterKindService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 仪种类Controller
 *
 * @author yajun_ren
 * @date 2021-07-27
 */
@RestController
@RequestMapping("/payfee/kind")
public class MeterKindController extends BaseController
{
    @Autowired
    private IMeterKindService meterKindService;

    /**
     * 查询仪种类列表
     */
    @ApiOperation(value = "查询仪种类列表", notes = "查询仪种类列表")
    @GetMapping("/list")
    public TableDataInfo list(MeterKind meterKind)
    {
        startPage();
        List<MeterKind> list = meterKindService.selectMeterKindList(meterKind);
        return getDataTable(list);
    }

    /**
     * 导出仪种类列表
     */
	@ApiOperation(value = "导出仪种类列表", notes = "导出仪种类列表")
    @PreAuthorize("@ss.hasPermi('payfee:kind:export')")
    @Log(title = "仪种类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MeterKind meterKind)
    {
        List<MeterKind> list = meterKindService.selectMeterKindList(meterKind);
        ExcelUtil<MeterKind> util = new ExcelUtil<MeterKind>(MeterKind.class);
        return util.exportExcel(list, "仪种类数据");
    }

    /**
     * 获取仪种类详细信息
     */
	@ApiOperation(value = "获取仪种类详细信息", notes = "获取仪种类详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:kind:query')")
    @GetMapping(value = "/{kindId}")
    public AjaxResult getInfo(@PathVariable("kindId") String kindId)
    {
        return AjaxResult.success(meterKindService.selectMeterKindById(kindId));
    }

    /**
     * 新增仪种类
     */
	  @ApiOperation(value = "新增仪种类", notes = "新增仪种类")
    @PreAuthorize("@ss.hasPermi('payfee:kind:add')")
    @Log(title = "仪种类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MeterKind meterKind)
    {
        return toAjax(meterKindService.insertMeterKind(meterKind));
    }

    /**
     * 修改仪种类
     */
	 @ApiOperation(value = "修改仪种类", notes = "修改仪种类")
    @PreAuthorize("@ss.hasPermi('payfee:kind:edit')")
    @Log(title = "仪种类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MeterKind meterKind)
    {
        return toAjax(meterKindService.updateMeterKind(meterKind));
    }

    /**
     * 删除仪种类
     */
	 @ApiOperation(value = "删除仪种类", notes = "删除仪种类")
    @PreAuthorize("@ss.hasPermi('payfee:kind:remove')")
    @Log(title = "仪种类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{kindIds}")
    public AjaxResult remove(@PathVariable String[] kindIds)
    {
        return toAjax(meterKindService.deleteMeterKindByIds(kindIds));
    }
}
